package com.jxw.launcher;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ListAdapter;
import com.jxw.adapter.FragmentGridViewAdapter;
import com.jxw.launcher.db.PreferenceHelper;
import com.jxw.launcher.model.CustomizeApp;
import com.jxw.launcher.util.Factory;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes.dex */
public abstract class BaseFragment extends Fragment {
    FragmentGridViewAdapter fragmentGridViewAdapter;
    GridView gridView;

    public View inflater(LayoutInflater layoutInflater, ViewGroup viewGroup, int i) {
        String readString;
        View inflate = layoutInflater.inflate(i, viewGroup, false);
        this.gridView = (GridView) inflate.findViewById(R.id.gridview);
        if (i == R.layout.ai_gridview_item) {
            readString = PreferenceHelper.readString(getContext(), "app", "page0", "3,4,5");
        } else {
            readString = PreferenceHelper.readString(getContext(), "app", "page1", "0,1,2,3,4,5");
        }
        String[] split = readString.split(",");
        ArrayList arrayList = new ArrayList();
        arrayList.clear();
        for (String str : split) {
            try {
                arrayList.add(Factory.allApps.get(Integer.parseInt(str)));
            } catch (Exception unused) {
            }
        }
        this.fragmentGridViewAdapter = new FragmentGridViewAdapter(getContext(), arrayList);
        GridView gridView = this.gridView;
        if (gridView != null) {
            gridView.setAdapter((ListAdapter) this.fragmentGridViewAdapter);
        }
        return inflate;
    }

    public void setGridData(List<CustomizeApp> list) {
        FragmentGridViewAdapter fragmentGridViewAdapter = this.fragmentGridViewAdapter;
        if (fragmentGridViewAdapter != null) {
            fragmentGridViewAdapter.setData(list);
            this.fragmentGridViewAdapter.notifyDataSetChanged();
        }
    }
}
